export default {
    apidomain: 'http://f.apiplus.net/'
}

//将字符串转换为需要格式的数组
export let str2Arr = (str) => {
    let newStr = str.replace("+", ",");
    return newStr.split(",");
}

//随机生成指定范围内指定个数的随机数
export let randomNum = (range,count) => {
    let arr = [];
    for (let i = 1; i <= range; i++) {
        arr[arr.length] = i;
    }
    let newArr = [];
    do {
        let ran = parseInt(Math.random() * arr.length);
        newArr.push(arr[ran]);
        arr.splice(ran,1);
    } while (newArr.length < count)
    return newArr;
}

//确认按钮变为可点击状态
export let comfirmed = () => {
    let btn = document.getElementById("confirmBtn");
    btn.removeAttribute("disabled");
    btn.style.color = "#000";
    btn.style.border = "1px solid #000";
}

//删除信息栏选中的号码
export let deleteCode = (arr,picked,buyCount) => {
    if(buyCount > 0) {
        if (!confirm("确定要删除吗？")) {
            return;
        }
        arr.splice(picked, 1);
        buyCount--;//选中彩票的数量减1
        return buyCount;
    }
}

//清空确认按钮的状态
export let clearConfirm = () => {
    let btn = document.getElementById("confirmBtn");
    btn.setAttribute("disabled", "");
    btn.style.color = "#000";
    btn.style.border = "none";
}

//设置选号栏选项状态
export let pick = (picked,index) => {
    let infos = document.querySelectorAll('.infoBox li');
    for (let i = 0; i < infos.length; i++) {
        infos[i].style.backgroundColor = '';
    }
    infos[index].style.backgroundColor = '#a1a1a1';
    picked = index;
    return picked;
}

//修改信息栏选中的号码
export let updateCode = (picked,isUpdate) => {
    if (picked < 0) {
        return;
    }
    //将常规的显示隐藏显示输入框
    isUpdate = picked;
    return isUpdate;
}

//清空信息栏列表
export let emptyCodes = (checkedBalls,buyCount) => {
    if (!confirm("确定要清空所选号码吗？")) {
        return;
    }
    checkedBalls.data = [];
    buyCount = 0;
    return buyCount;
}

